<extend name='Layout/index' />

<block name='breadcrumb'>
	<li>
		<i class="icon-home home-icon"></i>
		<a href="#">首页</a>
	</li>
	<li class="active">用户管理</li>
</block>

<block name='page_header'>
	<h1 style="font-size:14px">
		 用户管理
		<i class="icon-double-angle-right"></i>
		 会员管理
		<i class="icon-double-angle-right"></i>
		 会员修改
	</h1>
</block>

<block name='main_content'>
		<div style="font-size:14px;margin-left:10px;color:red;font-weight:bold;">基本信息</div>
		<div class="row">
			<div class="col-xs-12">
				<form class="form-horizontal" action='<{:U("update",array('uid'=>$data1['id'],'iid'=>$data2['id']))}>' method='post'>
				  <div class="form-group">
				    <label for="inputEmail3" class="col-sm-2 control-label">姓名</label>
				    <div class="col-sm-3">
				      <input type="text" class="form-control"  name='name' value="<{$data1.name}>">
				    </div>
				    <label for="inputEmail3" class="col-sm-2 control-label">婚姻状况</label>
				    <div class="col-sm-5">
				      <select name="status">
				      	<option value="0" <?php echo $data2['status']==0?'selected':''?>>未婚</option>
				      	<option value="1" <?php echo $data2['status']==1?'selected':''?>>离异</option>
				      	<option value="2" <?php echo $data2['status']==2?'selected':''?>>丧偶</option>
				      </select>
				    </div>
				  </div>

				  <div class="form-group">
				  	<label for="" class="col-sm-2 control-label">性别</label>
				  	<div class="col-sm-3">
				      <div class="checkbox">
				        <label>
				          <input type="radio" name='sex' value="0" <?php echo $data2['sex']==0?'checked':''?>>女
				          <input type="radio" name='sex' value="1" <?php echo $data2['sex']==1?'checked':''?>>男
				        </label>
				      </div>
				    </div>
				   

				    <label for="inputEmail3" class="col-sm-2 control-label">所在地区</label>
				    <div class="col-sm-5">
				      <select id='prov1' name='prov1'></select>
				      <select id='city1' name='city1'></select>
				      <select id='county1' name='county1'></select>
				    </div>
				  </div>
				 <div class="form-group">
				  	<label for="" class="col-sm-2 control-label">生日</label>
				     <div class="col-sm-3">
				      <select id='birthYear' name='birthday_year'>
				      	<?php 
				      		for($i=2015;$i>1950;$i--){   ?>
				      			<option value="<?php echo $i ?>" <?php echo $i == $data2['birthday_year']?'selected':'' ?>><?php echo $i ?></option>
				      	<?php	}
				      	?>
				      </select>
				      <select id='birthMonth' name='birthday_month'>
				      	<?php
				      		for($j=12;$j>0;$j--){	?>
				      			<option value="<?php echo $j ?>" <?php echo $j == $data2['birthday_month']?'selected':'' ?>><?php echo $j ?></option>
				      	<?php }
				      	?>
				      </select>
				      <select id='birthDay' name='birthday_day'>
				      	<option value="">请选择</option>
				      	<?php
				      		for($s=31;$s>0;$s--){  ?>
				      			<option value="<?php echo $s ?>"<?php echo $s == $data2['birthday_day']?'selected':'' ?>><?php echo $s ?></option>

				      	<?php	}
				      	?>
				      </select>
				    </div>

				    <label for="inputEmail3" class="col-sm-2 control-label">家乡</label>
				    <div class="col-sm-5">
				      <select id='prov2' name='prov2'></select>
				      <select id='city2' name='city2'></select>
				      <select id='county2' name='county2'></select>
				    </div>
				  </div>
				   <div class="form-group">
				    <label for="inputEmail3" class="col-sm-2 control-label">电话</label>
				    <div class="col-sm-3">
				      <input type="text" class="form-control"  name='phone' value="<{$data2.phone}>">
				    </div>

				    <label for="inputEmail3" class="col-sm-2 control-label">月收入</label>
				    <div class="col-sm-5">
				      <select name='money'>
				      	<option value="1" <?php echo $data2['money']==1?'selected':''?>>2000以下</option>
				      	<option value="2" <?php echo $data2['money']==2?'selected':''?>>2000-4000</option>
				      	<option value="3" <?php echo $data2['money']==3?'selected':''?>>4000-6000</option>
				      	<option value="4" <?php echo $data2['money']==4?'selected':''?>>6000-8000</option>
				      	<option value="5" <?php echo $data2['money']==5?'selected':''?>>8000-10000</option>
				      	<option value="6" <?php echo $data2['money']==6?'selected':''?>>10000以上</option>
				      </select>
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="inputEmail3" class="col-sm-2 control-label">邮箱</label>
				    <div class="col-sm-3">
				      <input type="text" class="form-control"  name='email' value="<{$data2.email}>">
				    </div>

				    <label for="inputEmail3" class="col-sm-2 control-label">购房情况</label>
				    <div class="col-sm-5">
				      <select name="house">
				      	<option value="0" <?php echo $data2['house']==0?'selected':''?>>以后告诉你</option>
				      	<option value="1" <?php echo $data2['house']==1?'selected':''?>>有房（无房贷）</option>
				      	<option value="2" <?php echo $data2['house']==2?'selected':''?>>有房（有房贷）</option>
				      	<option value="3" <?php echo $data2['house']==3?'selected':''?>>无房</option>
				      </select>
				    </div>
				  </div>
				  <div class="form-group">
				   	<label for="inputEmail3" class="col-sm-2 control-label">身高</label>
				    <div class="col-sm-3">
				      <input type="text" class="form-control"  name='height' value="<{$data2.height}>">
				    </div>

				    <label for="inputEmail3" class="col-sm-2 control-label">购车情况</label>
				    <div class="col-sm-5">
				      <select name="car">
				      	<option value="0" <?php echo $data2['car']==0?'selected':''?>>以后告诉你</option>
				      	<option value="1" <?php echo $data2['car']==1?'selected':''?>>有车（无房贷）</option>
				      	<option value="2" <?php echo $data2['car']==2?'selected':''?>>有车（有房贷）</option>
				      	<option value="3" <?php echo $data2['car']==3?'selected':''?>>无车</option>
				      </select>
				    </div>
				  </div>
				  <div class="form-group">
				   <label for="inputEmail3" class="col-sm-2 control-label">职业</label>
				    <div class="col-sm-3">
				      <input type="text" class="form-control"  name='pakistan' value="<{$data2.pakistan}>">
				    </div>
				    	

				   	<label for="inputEmail3" class="col-sm-2 control-label">学历</label>
				    <div class="col-sm-5">
				      <select name='edu'>
				      	<option value="1" <?php echo $data2['edu']==1?'selected':''?>>初中</option>
				      	<option value="2" <?php echo $data2['edu']==2?'selected':''?>>中专/职高/技校</option>
				      	<option value="3" <?php echo $data2['edu']==3?'selected':''?>>高中</option>
				      	<option value="4" <?php echo $data2['edu']==4?'selected':''?>>大专</option>
				      	<option value="5" <?php echo $data2['edu']==5?'selected':''?>>本科</option>
				      	<option value="6" <?php echo $data2['edu']==6?'selected':''?>>硕士</option>
				      	<option value="7" <?php echo $data2['edu']==7?'selected':''?>>博士</option>
				      	<option value="8" <?php echo $data2['edu']==8?'selected':''?>>博士后</option>
				      </select>
				    </div>
				 
				  </div>
				  </div>
				  <div class="form-group">
				  	<button style="background-color:#b74635;width:75px;height:46px;color:#fff;font-size:20px;border:none;border-radius:15px;margin-left:135px;margin-top:20px">修改</button>
				  </div>
				</form>
			</div>
		</div>

<script>
$(document).ready(function(){
	loadData($("#prov1"));
	loadData($("#prov2"));

	//绑定事件
	$("#prov1,#city1,#prov2,#city2").change(function(){
		var id=$(this).val();
		loadData($(this).next('select'),id);

		
	})

	//ajax 加载数据的方法
	function loadData(s,id){
		if(id === undefined){
			id = 0;
		}

		$.ajax({
		url:"<{:U('Admin/User/deal')}>",
		type:'get',
		data:{id:id},
		dataType:'json',
		success:function(dis){
			s.empty().hide();
			//清空下一个select并隐藏
			if(dis.length > 0){
				//console.log(dis);
				var pvid1 = <?php echo $data2['s_province'];?>;
				var cvid1 = <?php echo $data2['s_city'];?>;
				var tvid1 = <?php echo $data2['s_county'];?>;
				var pvid2 = <?php echo $data2['j_province'];?>;
				var cvid2 = <?php echo $data2['j_city'];?>;
				var tvid2 = <?php echo $data2['j_county'];?>;
				s.show();
				$.each(dis,function(index,value){
					var vid = value.id;
					if((vid == pvid1) || (vid == cvid1) || (vid == tvid1)){
						/*console.log(cvid);
						console.log(tvid);*/
						$('<option selected>').html(value.name).val(value.id).appendTo(s);
						pvid1 = '';
						cvid1 = '';
						tvid1 = '';

					}else{
						//console.log(2);
						$('<option>').html(value.name).val(value.id).appendTo(s);
					}
				
				
			})

				s.trigger('change');
			

			}

		}
		})	
	}

	
})
</script>
</block>